package com.corona.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.corona.Game;
import com.corona.game.util.SpriteProxy;
import com.corona.game.util.TextureCache;
import com.corona.game.util.audio.AudioLoader;
import com.sun.jna.platform.win32.WinError;
import java.util.ArrayList;
import java.util.Locale;

/* compiled from: Battle.java */
/* access modifiers changed from: package-private */
/* loaded from: pokewilds.jar:com/pkmngen/game/RegigigasBattle.class */
public class RegigigasBattle {
    RegigigasBattle() {
    }

    public static Action getIntroAction(Game game) {
        Draw drawBattle = new Draw(game, null);
        Action introAction = new DisplayText(game, "...", (String) null, (Action) null, new FadeMusic(game.currMusic, -(0.004f * (game.currMusic.getVolume() / 0.3f)), new WaitFrames(game, 90, new SetField(game.musicController, "startBattle", "gigas_battle1", new SplitAction(new CallMethod(game.uiBatch, "setColor", new Object[]{new Color(1.0f, 1.0f, 1.0f, 1.0f)}, null), new CallMethod(game.mapBatch, "setColor", new Object[]{new Color(0.5f, 0.5f, 0.5f, 1.0f)}, new WaitFrames(game, 190, new BattleIntro(new BattleIntro1(drawBattle, new PositionPlayers(game, null))))))))));
        if (game.battle.oppPokemon.isShiny) {
            introAction.append(new Battle.LoadAndPlayAnimation(game, "shiny", game.player.currPokemon, null));
        }
        introAction.append(new SplitAction(new WaitFrames(game, 4, new PlaySound(game.battle.oppPokemon, (Action) null)), new PokemonIntroAnim(new WaitFrames(game, 11, new DisplayText(game, "The battlefield quakes under REGIGIGAS' presence!", (String) null, (Action) null, new SetField(drawBattle, "shouldFadeAlpha", true, new SetField(drawBattle, "alsoDoShockwave", true, new WaitFrames(game, 60, new WaitFrames(game, 39, new SplitAction(new WaitFrames(game, 1, new DrawEnemyHealthGen2(game)), new MovePlayerOffScreen(game, new DisplayText(game, "Go! " + game.player.currPokemon.nickname.toUpperCase(Locale.ROOT) + "!", (String) null, true, false, (Action) new ThrowOutPokemonCrystal(game, null)))))))))))));
        if (game.player.currPokemon.isShiny) {
            introAction.append(new Battle.LoadAndPlayAnimation(game, "shiny", game.battle.oppPokemon, null));
        }
        introAction.append(new PlaySound(game.player.currPokemon, new WaitFrames(game, game.player.currPokemon.specie.cryLengthInFrames(), new WaitFrames(game, 6, new DrawFriendlyHealthGen2(game, new DisplayText.Clear(game, new WaitFrames(game, 15, new DrawBattleMenuNormal(game, null))))))));
        return introAction;
    }

    /* compiled from: Battle.java */
    /* loaded from: pokewilds.jar:com/pkmngen/game/RegigigasBattle$Draw.class */
    public static class Draw extends DrawBattle {
        Texture helper;
        Music soundEffect;
        public static SpriteProxy upperSprite;
        public static SpriteProxy lowerSprite;
        public static boolean doShockwave = false;
        public static boolean shouldBreathe = true;
        public static int breathingOffsetY = 0;
        public static boolean canMove = true;
        public static int specialAttackCounter = 0;
        public Action.Layer layer = Action.Layer.gui_130;
        double timer = 0.0d;
        double waveTimer = 25.132741228718345d;
        int waveSoundTimer = 0;
        Color color = new Color();
        double waveTimer2 = 0.0d;
        double alphaTimer = 0.0d;
        int breathingTimer = 300;
        public boolean shouldFadeAlpha = false;
        public boolean alsoDoShockwave = false;
        float fadeAlpha = 1.0f;
        SpriteProxy spriteProxy = new SpriteProxy(TextureCache.get(Gdx.files.internal("gigas_ground4.png")), 0, 0, 32, 32);
        Texture helper2 = TextureCache.get(Gdx.files.internal("battle/battle_bg4.png"));
        Sprite bg1 = new Sprite(TextureCache.get(Gdx.files.internal("battle/intro_frame6.png")), 0, 0, 160, 144);
        Texture textBox2 = TextureCache.get(Gdx.files.internal("battle/battle_bg6.png"));

        public Draw(Game game, Action nextAction) {
            super(game);
            this.nextAction = nextAction;
            if (game.battle.oppPokemon == null || !game.battle.oppPokemon.isShiny) {
                upperSprite = new SpriteProxy(TextureCache.get(Gdx.files.internal("pokemon/regigigas_upper.png")), 0, 0, 56, 56);
                lowerSprite = new SpriteProxy(TextureCache.get(Gdx.files.internal("pokemon/regigigas_lower.png")), 0, 0, 56, 56);
                return;
            }
            upperSprite = new SpriteProxy(TextureCache.get(Gdx.files.internal("pokemon/regigigas_upper_shiny.png")), 0, 0, 56, 56);
            lowerSprite = new SpriteProxy(TextureCache.get(Gdx.files.internal("pokemon/regigigas_lower_shiny.png")), 0, 0, 56, 56);
        }

        @Override // com.corona.game.DrawBattle, com.corona.game.Action
        public String getCamera() {
            return "gui";
        }

        @Override // com.corona.game.DrawBattle, com.corona.game.Action
        public Action.Layer getLayer() {
            return this.layer;
        }

        @Override // com.corona.game.DrawBattle, com.corona.game.Action
        public void firstStep(Game game) {
            this.soundEffect = AudioLoader.loadMusic("sounds/ap3.ogg");
            this.soundEffect.setLooping(false);
            this.soundEffect.setVolume(0.65f);
            canMove = true;
            specialAttackCounter = 0;
        }

        /* JADX DEBUG: Failed to insert an additional move for type inference into block B:105:0x02ed */
        /* JADX WARN: Type inference failed for: r15v0 */
        /* JADX WARN: Type inference failed for: r15v1 */
        /* JADX WARN: Type inference failed for: r15v2, types: [double] */
        /* JADX WARN: Type inference failed for: r15v3, types: [double] */
        /* JADX WARNING: Unknown variable types count: 1 */
        @Override // com.corona.game.DrawBattle, com.corona.game.Action
        /* Code decompiled incorrectly, please refer to instructions dump. */
        public void step(Game r11) {
            /*
            // Method dump skipped, instructions count: 1215
            */
            throw new UnsupportedOperationException("Method not decompiled: com.corona.game.RegigigasBattle.Draw.step(com.corona.Game):void");
        }
    }

    /* compiled from: Battle.java */
    /* access modifiers changed from: package-private */
    /* loaded from: pokewilds.jar:com/pkmngen/game/RegigigasBattle$PositionPlayers.class */
    public static class PositionPlayers extends Action {
        public Action.Layer layer = Action.Layer.gui_140;
        int timer = 0;
        float xPos = 0.0f;

        public PositionPlayers(Game game, Action nextAction) {
            super(new Object[0]);
            this.nextAction = nextAction;
            game.player.battleSprite.setPosition(160.0f, 48.0f);
            game.battle.oppPokemon.sprite.setPosition(-49.0f, 88.0f);
        }

        @Override // com.corona.game.Action
        public void firstStep(Game game) {
            SpriteProxy.darkenAllColors3 = true;
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            if (this.timer <= 144) {
                this.xPos = game.player.battleSprite.getX() - 1.0f;
                game.player.battleSprite.setX(this.xPos);
                this.xPos = game.battle.oppPokemon.sprite.getX() + 1.0f;
                game.battle.oppPokemon.sprite.setX(this.xPos);
            }
            this.timer++;
            if (this.timer > 159) {
                SpriteProxy.darkenAllColors3 = false;
                game.actionStack.remove(this);
                game.insertAction(this.nextAction);
            }
        }
    }

    /* compiled from: Battle.java */
    /* access modifiers changed from: package-private */
    /* loaded from: pokewilds.jar:com/pkmngen/game/RegigigasBattle$BattleIntro1.class */
    public static class BattleIntro1 extends Action {
        Sprite frame;
        Action nextAction2;
        Sprite bgSprite;
        public Action.Layer layer = Action.Layer.gui_139;
        ArrayList<Sprite> frames = new ArrayList<>();

        public BattleIntro1(Action nextAction2, Action nextAction) {
            super(new Object[0]);
            this.nextAction = nextAction;
            this.nextAction2 = nextAction2;
            Texture text = TextureCache.get(Gdx.files.internal("battle/battle_intro_anim1_sheet1.png"));
            for (int i = 0; i < 28; i++) {
                this.frames.add(new Sprite(text, i * 160, 0, 160, 144));
            }
            for (int i2 = 0; i2 < 95; i2++) {
                this.frames.add(new Sprite(text, (int) WinError.ERROR_REQUEST_REFUSED, 0, 160, 144));
            }
            this.bgSprite = new Sprite(TextureCache.get(Gdx.files.internal("battle/intro_frame3.png")), 0, 0, 160, 144);
        }

        @Override // com.corona.game.Action
        public String getCamera() {
            return "gui";
        }

        @Override // com.corona.game.Action
        public Action.Layer getLayer() {
            return this.layer;
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            this.frame = this.frames.get(0);
            if (this.frame != null) {
                this.frame.draw(game.uiBatch);
            }
            this.frames.remove(0);
            game.uiBatch.draw(this.bgSprite, -160.0f, 0.0f);
            game.uiBatch.draw(this.bgSprite, 160.0f, 0.0f);
            game.uiBatch.draw(this.bgSprite, 0.0f, -144.0f);
            game.uiBatch.draw(this.bgSprite, 0.0f, 144.0f);
            if (this.frames.isEmpty()) {
                game.insertAction(this.nextAction);
                game.insertAction(this.nextAction2);
                game.actionStack.remove(this);
            }
        }
    }

    /* compiled from: Battle.java */
    /* loaded from: pokewilds.jar:com/pkmngen/game/RegigigasBattle$SpecialAttack.class */
    public static class SpecialAttack extends Action {
        public Action.Layer layer = Action.Layer.gui_0;
        int timer = 0;

        public SpecialAttack(Action nextAction) {
            super(new Object[0]);
            this.nextAction = nextAction;
        }

        @Override // com.corona.game.Action
        public String getCamera() {
            return "gui";
        }

        @Override // com.corona.game.Action
        public Action.Layer getLayer() {
            return this.layer;
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            if (this.timer == 0) {
                Draw.canMove = false;
                Draw.breathingOffsetY = 0;
                Draw.shouldBreathe = false;
            } else if (this.timer == 96) {
                Draw.doShockwave = true;
            } else if (this.timer == 116) {
                Draw.breathingOffsetY = -17;
                game.insertAction(new Battle.LoadAndPlayAnimation(game, "neutral_effective", game.player.currPokemon, null));
            } else if (this.timer == 160) {
                SpriteProxy.darkenAllColors3 = false;
                Draw.shouldBreathe = true;
            } else if (this.timer == 170) {
                Draw.canMove = true;
            } else if (this.timer == 180) {
                SpriteProxy.darkenAllColors2 = false;
            } else if (this.timer == 181) {
                game.insertAction(this.nextAction);
            } else if (this.timer == 200) {
                SpriteProxy.darkenAllColors1 = false;
            }
            if (this.timer < 160) {
                SpriteProxy.darkenAllColors3 = true;
            } else if (this.timer < 180) {
                SpriteProxy.darkenAllColors2 = true;
            } else if (this.timer < 200) {
                SpriteProxy.darkenAllColors1 = true;
            }
            if (this.timer >= 170) {
                if (this.timer < 182) {
                    Draw.breathingOffsetY++;
                } else if (this.timer < 192 && this.timer % 2 == 0) {
                    Draw.breathingOffsetY++;
                }
            }
            this.timer++;
            if (this.timer > 200) {
                game.actionStack.remove(this);
            }
        }
    }
}
